package com.get.backstage;

import com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.util.text.BasicTextEncryptor;
import org.junit.jupiter.api.Test;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.StandardEnvironment;

/**
 *
 */
@SpringBootTest
public class MysqlS {

    @Test
    public void test() {

//        // 对应配置文件中配置的加密密钥
//        System.setProperty("jasypt.encryptor.password", "zhejianglab");
//        StringEncryptor stringEncryptor = new DefaultLazyEncryptor(new StandardEnvironment());
////		System.out.println("加密： " + stringEncryptor.encrypt("Mysql"));
//        System.out.println("加密： " + stringEncryptor.encrypt("Root"));
//        // root 加密后为BJCbw/KTdtyg/GikiMmzSxdfdsoxsTFRnOV++S/YnAPlu+FwZIp3Gt11B0QUyGPS
//        // Mysql加密后为 6kMXpifgAnZvPOaVDsChRDd/loHPnGxEm6xRBJjG8H4RQ08YbRrA5BxfIlA1MxOn
//        // Root 加密后为 okhbVaSWXz249EZbWxk+wZYAPVltwPVv2L2WBI+HgZGKB/RVumtL4Lb+pNEUpn/y


        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
        //加密所需的salt
        textEncryptor.setPassword("123456");
        //要加密的数据（数据库的用户名或密码）
        String username = textEncryptor.encrypt("root");
        String password = textEncryptor.encrypt("123456");
        System.out.println("username:" + username);
        System.out.println("password:" + password);

    }


}
